package problemsolving;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

public class Solution {
	private static int minDays(int[] v, int K, List<Stack<Integer>> sol, int ind) {
		if(ind >= v.length)
			return sol.size();
		int minDays = v.length;
		for(int i = 0; i < sol.size(); i++) {
			// check by solving ind problem on day i
			Stack<Integer> solDayi = sol.get(i);
			if(Math.abs(v[ind] - v[solDayi.peek()]) < K)
				continue;
			solDayi.push(ind);
			int d = minDays(v, K, sol, ind + 1);
			if(d < minDays)
				minDays = d;
			solDayi.pop();
		}
		// check by solving ind problem on a new day
		Stack<Integer> solDayi = new Stack<Integer>();
		solDayi.push(ind);
		sol.add(solDayi);
		int d = minDays(v, K, sol, ind + 1);
		if(d < minDays)
			minDays = d;
		sol.remove(sol.size() - 1);
		return minDays;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		try {
			int T = in.nextInt();
			for(int t = 0; t < T; t++) {
				int N = in.nextInt(), K = in.nextInt(), v[] = new int[N];
				for(int n = 0; n < N; n++)
					v[n] = in.nextInt();
				System.out.println(minDays(v, K, new ArrayList<Stack<Integer>>(), 0));
			}
		} finally {
			in.close();
		}
	}
}
